package com.pubg.util;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 图片不重名
 */
public class StringUtil {
    public static String easyPicName(String picName){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        String date = sdf.format(new Date());
        long currTime = System.currentTimeMillis();
        String md5 = SecurityUtil.md5hex3(picName).substring(0,10);
        return date+"-"+currTime+ md5 +".png";
    }
    public static String easyPicName(String picName,String ext){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        String date = sdf.format(new Date());
        long currTime = System.currentTimeMillis();
        String md5 = SecurityUtil.md5hex3(picName).substring(0,10);
        return date+"-"+currTime+ md5 +"."+ext;
    }


    public static void main(String[] args) {
        System.out.println(StringUtil.easyPicName(""));
    }
}
